const A = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    searchContent: '',
    searchList: []
  },
  // 搜索
  search(e) {
    console.log(e);
    let content = e.detail.value;
    this.setData({
      searchFlag: e.detail.value ? true : false,
      searchContent: e.detail.value
    })
    this.data.searchFlag && this.getSearchList();
  },
  getSearchList() {
    let config = {
      searchContent: this.data.searchContent
    }
    A.updata.search(config).then(res => {
      console.log(res);
      this.setData({
        searchList: res.results
      })
    })
  },

  toDetail(e) {
    let type = A.C(e).type;
    let id = A.C(e).id;
    if (type == 1) {
      wx.navigateTo({
        url: `/pages/mall/goodsDetail/shopInfo/shopInfo?id=${id}`
      })
    } else if (type == 2) {
      wx.navigateTo({
        url: `/pages/videos/videoDetail/videoDetail?id=${id}`
      })
    } else if (type == 3) {
      wx.navigateTo({
        url: `/pages/index/localLives/localLivesInfo/localLivesInfo?id=${id}`
      })
    } else if (type == 4) {
      wx.navigateTo({
        url: `/pages/mall/goodsDetail/shopInfo/shopInfo?id=${id}`
      })
    } else if (type == 5) {
      wx.navigateTo({
        url: `/pages/index/article/article?id=${id}&flag=1`
      })
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})